package cn.yujiago.miaosha.controller;

import cn.yujiago.miaosha.dto.CodeMsg;
import cn.yujiago.miaosha.dto.Result;
import cn.yujiago.miaosha.entity.Order;
import cn.yujiago.miaosha.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @RequestMapping("/detail")
    public Result<Order> getDetail(@RequestParam("orderId") Long orderId){

        Order order = orderService.getOrderById(orderId);

        if(order != null){
            return Result.success(order);
        }else{
            return Result.error(CodeMsg.ORDER_NOT_EXIST);
        }

    }

}
